package com.practice.controller.admin;

import com.practice.common.result.Result;
import com.practice.pojo.admin.dto.AdminUserDTO;
import com.practice.pojo.admin.vo.AdminUserVO;
import com.practice.pojo.user.dto.UserDTO;
import com.practice.service.admin.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.PublicKey;

@RestController
@RequestMapping("/sys_user")
public class AdminUserController {

    @Autowired
    private AdminUserService adminUserService;

    //0
    @GetMapping("/list")
    public Result list(AdminUserDTO adminUserDTO){
        return adminUserService.list(adminUserDTO);
    }

    //0
    @PostMapping("/add")
    public Result add(@RequestBody AdminUserDTO adminUserDTO){
        adminUserService.add(adminUserDTO);
        return Result.success();
    }

    //1
    @GetMapping("/del")
    public Result delete(String id){
        adminUserService.delete(id);
        return Result.success();
    }

    //0 role_id[]
    @GetMapping("/rowInfo")
    public Result rowInfo(String id){
        return Result.success(adminUserService.rowInfo(id));
    }

    @PostMapping("/update")
    public Result updateUser(@RequestBody AdminUserDTO dto){
        adminUserService.updateUser(dto);
        return Result.success();
    }
}
